package net.borlis.sample.horses.process;

import net.borlis.sample.horses.core.Horse;
import net.borlis.sample.horses.core.Odds;

import java.util.Map;
import java.util.Set;

/**
 * Created by Alexander on 22.12.2014.
 */
public class Bett {

    private Horse horse;
    private Integer amount;

    public Bett(Integer horseNumber, Odds odds, Integer amount) throws IllegalArgumentException {
        Set<Map.Entry<Horse, Integer>> horses = odds.entrySet();
        for (Map.Entry<Horse, Integer> entry : horses) {
            if (entry.getKey().getId().equals(horseNumber)) {
                this.horse = entry.getKey();
                break;
            }
        }
        if (this.horse == null) {
            throw new IllegalArgumentException("wrong horse number");
        }
        this.amount = amount;
        System.out.println("Your bet is $" + amount + " on " + horse.getName());
    }

    public Horse getHorse() {
        return horse;
    }

    public Integer getAmount() {
        return amount;
    }
}
